﻿using System;

namespace DotNet.WinForm.Utilities.Controls
{
    public class DotNetDataGridControl : DevExpress.XtraGrid.GridControl
    {
    }

    public class DotNetDataGridView : DevExpress.XtraGrid.Views.Grid.GridView
    {
        public DotNetDataGridView()
        {
            this.CustomDrawRowIndicator += new DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventHandler(DotNetDataGridView_CustomDrawRowIndicator);
        }

        private bool _RowPostPaint = false;

        public Boolean ShowRowNumber { get { return _RowPostPaint; } set { _RowPostPaint = value; } }

        private void DotNetDataGridView_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
        {
            if (this.GridControl != null && e.RowHandle > -1)
            {
                var ctl = this.GridControl as DotNetDataGridControl;
                if (ShowRowNumber)
                {
                    e.Info.DisplayText = (e.RowHandle + 1).ToString();
                }
            }
        }
    }
}